package com.glorystone.ins.domain;


import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;

import java.io.IOException;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;

/**
 * Created by wangwei on 2018/3/13.
 */
public class CustomLocalDateSerializer extends JsonSerializer<LocalDate> {


    @Override
    public void serialize(LocalDate localDate, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
        String format = localDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
        jsonGenerator.writeString(format);
    }
}
